package com.example.springsecuritydemo.utils;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

public class BcryptTest {
    public static void main(String[] args) {
        // 创建BCryptPasswordEncoder对象，设置加密强度为4，默认为10，值越小加密越快
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(10);
        
        // 使用BCrypt加密"password"
        String rawPassword = "password";
        String encodedPassword = encoder.encode(rawPassword);
        System.out.println("原始密码: " + rawPassword);
        System.out.println("加密后的密码: " + encodedPassword);
        System.out.println("验证结果: " + encoder.matches(rawPassword, encodedPassword));
    }
}